package com.ruoyi.controller.jpjs.socialpayment;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.service.jpjs.PublicService;
import com.ruoyi.service.jpjs.socialpayment.SocialPaymentService;
import com.ruoyi.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zeo
 * 合同社保公积金分析
 */

@Controller
@RequestMapping("/socialPayment")
public class SocialPaymentController extends BaseController {

    @Autowired
    SocialPaymentService socialPaymentService;

    @Autowired
    PublicService publicService;

    private String prefix = "jpjs/socialpayment";

    @GetMapping()
    public String socialPayment(ModelMap mmap) {
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/socialPayment";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        startPage();
        return getDataTable(socialPaymentService.list(map));
    }

    @GetMapping("/add")
    public String add(ModelMap mmap) {
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/add";
    }

    @RequestMapping("/add")
    @ResponseBody
    public AjaxResult add(@RequestParam Map map) {
        return toAjax(socialPaymentService.add(map));
    }

    @GetMapping("/edit/{id}")
    public String edit(ModelMap mmap, @PathVariable("id") String id) {
        mmap.put("data", socialPaymentService.findDataById(id));
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/edit";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestParam Map map) {
        return toAjax(socialPaymentService.edit(map));
    }

    @RequestMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(socialPaymentService.remove(ids));
    }

    @RequestMapping("/getLastMonthData")
    @ResponseBody
    public BaseResult getLastMonthData(@RequestParam Map map) throws Exception {
        return socialPaymentService.getLastMonthData(map);
    }
}


